package com.example.microservicesimpleconsumermovie.controller;

import com.example.microservicesimpleconsumermovie.model.User;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author wzg
 * @date 2021/10/16 22:20
 */
@RestController
@RequiredArgsConstructor(onConstructor_ ={@Autowired} )
public class MovieController {
    private final RestTemplate restTemplate;
    @GetMapping("/user/{id}")
    public User findById(@PathVariable Long id){
        return restTemplate.getForObject("http://localhost:8000/"+id,User.class);
    }
}
